package ali;

import java.util.concurrent.ThreadPoolExecutor;

public class Main2 {
    public static void main(String[] args) {
        Object o1 = new Object();
        Object o2 = new Object();
        getLock(o1,o2);
        new Thread(() -> {
            getLock(o2,o1);
        }).start();

        getLock(o1,o2);

    }

    static void getLock(Object o1,Object o2){
        synchronized (o1){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (o2){
                System.out.println("没有锁住");
            }
        }
    }
}
